Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.category: Add color option #5011

Merged
merged 6 commits into from
Feb 14, 2025
Merged

Conversation

NishantBansal2003
Copy link
Contributor

Enhancement: Add Color Option to Category Output

Fixes: #4071

Overview

This PR introduces a new color option for r.category, allowing users to retrieve category colors alongside labels. This enhancement is useful for visualization workflows where knowing both the category label and its associated color is important.

Changes Made

  • Added a color option that allows specifying the output format:
    • none (default) – No color output.
    • rgb – Outputs colors in rgb(r, g, b) format.
    • hex – Outputs colors in #RRGGBB format.
    • triplet – Outputs colon-separated R:G:B values.
  • Updated PLAIN output format to include color:
    1 trees, very green rgb(68, 1, 84)
    2 water, very deep rgb(253, 231, 37)
    
  • Updated JSON output format to include color:
    [
        {
            "category": 1,
            "description": "trees, very green",
            "color": "rgb(68, 1, 84)"
        },
        {
            "category": 2,
            "description": "water, very deep",
            "color": "rgb(253, 231, 37)"
        }
    ]

Testing & Validation

  • Existing feature tests were taken from the r.category doctest file.
  • New feature tests for the color option have been added at the end.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
@github-actions github-actions bot added raster Related to raster data processing Python Related code is in Python C Related code is in C module labels Jan 30, 2025
echoix and others added 2 commits February 2, 2025 15:58
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
raster/r.category/main.c Outdated Show resolved Hide resolved
raster/r.category/main.c Outdated Show resolved Hide resolved
raster/r.category/main.c Outdated Show resolved Hide resolved
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this looks great, just couple comments.

NishantBansal2003 and others added 2 commits February 4, 2025 11:16
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
@NishantBansal2003
Copy link
Contributor Author

Could you please clarify if anything needs to be done for this PR or if there are any additional comments? @petrasovaa @wenzeslaus

@petrasovaa petrasovaa merged commit 3ab4f38 into OSGeo:main Feb 14, 2025
27 checks passed
@github-actions github-actions bot added this to the 8.5.0 milestone Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C libraries module Python Related code is in Python raster Related to raster data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] r.category: add color option
4 participants